package com.letoken.platform.repo.app.manager;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.letoken.platform.repo.app.dao.AppUserWalletMapper;
import com.letoken.platform.repo.app.po.AppUserWallet;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author wyl
 * @date 2022/12/20 15:44
 * @Version 1.0
 */
@Log4j2
@Repository
public class AppUserWalletManager {

    @Autowired
    private AppUserWalletMapper walletMapper;


    public AppUserWallet queryWalletByToken(Integer userId, Integer tokenId) {
        LambdaQueryWrapper<AppUserWallet> walletWrapper = Wrappers.lambdaQuery();
        walletWrapper.eq(AppUserWallet::getUserId, userId).eq(AppUserWallet::getTokenId, tokenId);
        return walletMapper.selectOne(walletWrapper);
    }

    public List<AppUserWallet> queryWalletByUserId(Integer userId, List<Integer> tokenIdList) {
        LambdaQueryWrapper<AppUserWallet> walletWrapper = Wrappers.lambdaQuery();
        walletWrapper.eq(AppUserWallet::getUserId, userId).in(AppUserWallet::getTokenId, tokenIdList);
        return walletMapper.selectList(walletWrapper);
    }
}
